@extends('layouts.default')
@section('content')
    <div class="card">
        <div class="card-header">
            用户列表
        </div>
        <div class="card-body">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>用户名称</th>
                    <th width="300px">操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($users as $user)
                    <tr>
                        <td scope="row">{{$user -> id}}</td>
                        <td>{{$user -> name }}</td>
                        <td>
                            <div class="btn-group">
                                @can('delete',$user)
                                    <form action="{{route('user.destroy',$user)}}" method="post">
                                        @csrf @method('DELETE')
                                        <button type="submit" class="btn btn-danger">删除</button>
                                    </form>
                                @endcan
                                @can('update' , $user)
                                    <a class="btn btn-info" href="{{route('user.edit',$user)}}" role="button">修改</a>
                                @endcan
                                <a class="btn btn-primary" href="{{route('user.show',$user)}}" role="button">查看</a>
                            </div>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        <div class="card-footer text-muted">
            {{$users->render()}}
        </div>
    </div>
@endsection
